#include "stdafx.h"
#include "Session.h"

#include <windows.h>

#include "../Include/cJSON.h"
#include "RuleModel.h"

#include "SessionGroup.h"

static const char* pszURIAIMissionProgress = "/PerformanceTest/req_mission_progress";
static const char* pszURIAIBattleProgress = "/PerformanceTest/req_battle_progress";
static const char* pszURIAIRaidProgress = "/PerformanceTest/req_raid_progress";

static const char* pszURIEnterGame = "/ContentGate/req_enter_game";

// lobby
static const char* pszURIReadyToPlay = "/GameLobby/req_ready_to_play"; // User initial data to play
static const char* pszURISetSpecies = "/GameLobby/req_set_species";
static const char* pszURISetName = "/GameLobby/req_set_name";

// mission
static const char* pszURIUserEnterMission = "/GameLobby/req_enter_mission"; // User area, quest info

static const char* pszURIMissionQuestProgress = "/GameMission/req_quest_progress";
static const char* pszURIMissionBossProgress = "/GameMission/req_boss_progress";

// ***
static const char* pszURIUserAreaList = "/GameMission/area/list";
static const char* pszURIUserQuestList = "/GameMission/quest/list";

// battle
static const char* pszURIEnterBattle = "/GameLobby/req_enter_battle";

static const char* pszURIBattleRankList = "/GameBattle/req_rank_list";
static const char* pszURIBattleRivalList = "/GameBattle/req_rival_list";
static const char* pszURIBattleCombatStart = "/GameBattle/req_combat_start";
static const char* pszURIBattleHistoryList = "/GameBattle/req_history_list";

static const char* pszURIBattleFirstRival = "/GameBattle/req_first_rival";
static const char* pszURIBattleFirstStart = "/GameBattle/req_first_start";

// raid
static const char* pszURIEnterRaid = "/GameLobby/req_enter_raid";

static const char* pszURIRaidCurrent = "/GameRaid/get/current";
static const char* pszURIRaidStart = "/GameRaid/req_start";
static const char* pszURIRaidResult = "/GameRaid/req_result";

// enhance
static const char* pszURIEnhanceUpgrade = "/GameEnhance/req_upgrade";
static const char* pszURIEnhanceEvolution = "/GameEnhance/req_evolution";

// shop
static const char* pszURIEnterShop = "/GameLobby/req_enter_shop";

static const char* pszURIShopDrawCard = "/GameShop/req_draw_card";
static const char* pszURIShopBuyItem = "/GameShop/req_buy_item";
static const char* pszURIShopBuyCoin = "/GameShop/req_buy_coin";

// manage
static const char* pszURIEnterManage = "/GameLobby/req_enter_manage";

static const char* pszURIManageChangeMsg = "/GameManage/req_change_msg";
static const char* pszURIManageCardList = "/GameManage/req_card_list";
static const char* pszURIManageSellCard = "/GameManage/req_sell_card";
static const char* pszURIManageItemList = "/GameManage/req_item_list";
static const char* pszURIManageUseItem = "/GameManage/req_use_item";
static const char* pszURIManageUpdateStat = "/GameManage/req_update_stat";
// *** 
static const char* pszURIManageLockCard = "/GameManage/req_lock_card";

// formation
static const char* pszURIEnterFormation = "/GameLobby/req_enter_formation";

static const char* pszURIFormationSet = "/GameFormation/req_set";

// friend
static const char* pszURIFriendList = "/GameFriend/req_list";
static const char* pszURIFriendDelete = "/GameFriend/req_delete";

static const char* pszURIFriendProposeList = "/GameFriend/req_propose_list";
static const char* pszURIFriendAccept = "/GameFriend/req_accept";
static const char* pszURIFriendReject = "/GameFriend/req_reject";
static const char* pszURIFriendCancel = "/GameFriend/req_cancel";

static const char* pszURIFriendCandidateList = "/GameFriend/req_candidate_list";
static const char* pszURIFriendSearch = "/GameFriend/req_search";
static const char* pszURIFriendRequest = "/GameFriend/req_request";

// post
static const char* pszURIEnterPost = "/GameLobby/req_enter_post";

static const char* pszURIPostList = "/GamePost/req_list";
static const char* pszURIPostCheck = "/GamePost/req_check";
static const char* pszURIPostGetItem = "/GamePost/req_get_item";
static const char* pszURIPostDelete = "/GamePost/req_delete";

// system
static const char* pszURIUserRegist = "/webview/user/regist_operate";
static const char* pszURIUserRefresh = "/common/user/refresh";
	// noti
static const char* pszURINotiLive = "/common/noti/live";
static const char* pszURINotiAlert = "/common/noti/alert";
	// banner
static const char* pszURIFrontBanner = "/common/front_banner";

CSession::CSession(void)
{
}

CSession::~CSession(void)
{
	m_pVSFramework->Finalize();

	delete m_pVSFramework;
	m_pVSFramework = nullptr;
}

void CSession::Initialize( CSessionGroup* pGroup, int session_id )
{
	m_pOwnGroup = pGroup;
	int groupID = pGroup->GetGroupID();

	m_sessionID = ++CSessionGroup::s_generateSessionID;

	m_FrameworkHandler.Create( this );

	m_pVSFramework = VSFramework::CreateNewInstance();
	m_pVSFramework->Initialize( PLATFORM_GOOGLE, &m_FrameworkHandler);
	m_pVSFramework->StartModuleCertification("http://175.126.104.163", "LTCBK", "20131032_1900", 1 );

	m_ActionManager.Create( this, groupID );
	//m_ActionManager.Start();

	BindActionHandler();
	BindNetworkHandler();
	BindMsgHandlers();
}

void CSession::Update()
{
	m_pVSFramework->Update();
	m_ActionManager.Update();

	VSFramework::INetworkContext* context = NULL;

	while( true )
	{
		context = m_pVSFramework->GetUnhandledMsg();
		if( context == NULL )
			break;

		unsigned char forwarded_msg_id = context->GetMsgID();
		if( forwarded_msg_id != VS_FORWARDEDMSG_CONTENT_MSG )
		{
			switch(forwarded_msg_id)
			{
			case VS_FORWARDEDMSG_MODULE_CERTIFICATED :
				{
					Put( L"module certificated! session[%d]", m_sessionID );
					char szID [10] = {0, };
					sprintf_s(szID, 10, "%d", m_sessionID);
					m_pVSFramework->StartContentService(szID, "1234");
				}
				break;

			case VSFRAMEWORK_LOGIN_ACK :
				Put( L"login completed! session[%d]", m_sessionID );
				m_ActionManager.Start();
				break;

			case VSFRAMEWORK_NETWORK_ERROR :
				Put( L"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
				Put( L"network error! session[%d]", m_sessionID );
				Put( L"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );

				m_ActionManager.Resume();
				break;
			}
		}
		else
		{
			cJSON* packet = context->GetJsonData();
			cJSON* packet_msg_id = cJSON_GetObjectItem( packet, "msg_id" );
			if( packet_msg_id == NULL )
				return;

			m_ActionManager.Resume();

			wchar_t ack_msg[ 1024 ];
			::ZeroMemory( ack_msg, sizeof(ack_msg) );
			size_t lv_Len = ::MultiByteToWideChar(CP_ACP, 0, packet_msg_id->valuestring, strlen(packet_msg_id->valuestring), ack_msg, 1024);

			Put(L"ack!! session[%d] msg[%s]", m_sessionID, ack_msg );
	
			MAP_HANDLERS::iterator it = m_mapMsgHandlers.find( packet_msg_id->valuestring );
			if( it != m_mapMsgHandlers.end() )
			{
				cJSON* packetBody = cJSON_GetObjectItem( packet, "ret_data" );
				(this->*it->second)( packetBody );
			}
		}

		m_pVSFramework->DeleteContext( context );
	}
}

void CSession::ExecuteAction( int execution_count, const std::string& action_name )
{
	auto it = m_actions.find( action_name );
    if( it == m_actions.end() )
    {
        //exception! trying to execute unknown action!
        return;
    }

	//invoke!
	action_handler& handler = it->second;
	(this->*handler)( execution_count );
}

void CSession::InvokeAction( const request_actor& actor )
{
	auto& action = actor();
	
	cJSON* value = NULL;
	if(action.second.empty() == false || action.second.length() > 1)
	{
		value = cJSON_CreateObject();
		cJSON* data = cJSON_CreateString(action.second.c_str());
		cJSON_AddItemToObject(value, "", data);
	}

	wchar_t request[ 1024 ];
	::ZeroMemory( request, sizeof(request) );
	size_t lv_Len = ::MultiByteToWideChar(CP_ACP, 0, action.first.c_str(), action.first.size(), request, 1024);

	Put( L"req[%s] session[%d]", request, m_sessionID );
	m_pVSFramework->SendRequest( action.first.c_str(), value );

	m_ActionManager.Pause();

	cJSON_Delete(value);
}

std::string generate( const char* format, ... )
{
	char buffer[ 1024 ];
	va_list va;
	va_start( va, format );
	vsprintf_s( buffer, _countof(buffer), format, va );
	va_end( va );

	return std::string( buffer );
}

void CSession::JobFinished()
{
	//m_pOwnGroup->JobFinished( m_sessionID );
}

void CSession::BindNetworkHandler()
{
	m_requests["user_reset"] = [this]() { return PAIR_STR("/common/user/reset", generate("vs_id=%d&vs_pwd=1234", m_sessionID)); };

	m_requests["req_mission_progress"] = [this]() { return PAIR_STR(pszURIAIMissionProgress, generate("")); };
	m_requests["req_battle_progress"] = [this]() { return PAIR_STR(pszURIAIBattleProgress, generate("")); };
	m_requests["req_raid_progress"] = [this]() { return PAIR_STR(pszURIAIRaidProgress, generate("")); };

	// enter game
	m_requests["req_enter_game"] = [this]() { return PAIR_STR(pszURIEnterGame, generate("")); };

	// lobby
	m_requests["req_ready_to_play"] = [this]() { return PAIR_STR(pszURIReadyToPlay, generate("")); };
	m_requests["req_set_species"] = [this]() { return PAIR_STR(pszURISetSpecies, generate("species=%d", m_sessionID%3)); };
	m_requests["req_set_name"] = [this]() { return PAIR_STR(pszURISetName, generate("name=%s%d", "Dummy", m_sessionID)); };

	// mission
	m_requests["req_enter_mission"] = [this]() { return PAIR_STR(pszURIUserEnterMission, generate("")); };

	m_requests["req_quest_progress"] = [this]() { return PAIR_STR(pszURIMissionQuestProgress, generate("")); };

	// battle
	m_requests["req_enter_battle"] = [this]() { return PAIR_STR(pszURIEnterBattle, generate("")); };

	m_requests["req_rank_list"] = [this]() { return PAIR_STR(pszURIBattleRankList, generate("")); };
	m_requests["req_rival_list"] = [this]() { return PAIR_STR(pszURIBattleRivalList, generate("rank_type=1&range_min=1&range_max=10")); };
	m_requests["req_combat_start"] = [this]() { return PAIR_STR(pszURIBattleCombatStart, generate("rival_pvid=%d&bl_idx_for_revenge=%d", m_sessionID+1, 0)); };
	m_requests["req_history_list"] = [this]() { return PAIR_STR(pszURIBattleHistoryList, generate("")); };

	m_requests["req_first_rival"] = [this]() { return PAIR_STR(pszURIBattleFirstRival, generate("")); };
	m_requests["req_first_start"] = [this]() { return PAIR_STR(pszURIBattleFirstStart, generate("")); };

	// raid
	m_requests["req_enter_raid"] = [this]() { return PAIR_STR(pszURIEnterRaid, generate("")); };

	m_requests["req_start"] = [this]() { return PAIR_STR(pszURIRaidStart, generate("raid_id=%d", 1)); };
	m_requests["req_result"] = [this]() { return PAIR_STR(pszURIRaidResult, generate("atk_cnt=%d", 3)); };

	// enhance
	m_requests["req_upgrade"] = [this]() { return PAIR_STR(pszURIEnhanceUpgrade, generate("")); };
	m_requests["req_evolution"] = [this]() { return PAIR_STR(pszURIEnhanceEvolution, generate("")); };

	// shop
	m_requests["req_enter_shop"] = [this]() { return PAIR_STR(pszURIEnterShop, generate("")); };

	m_requests["req_draw_card"] = [this]() { return PAIR_STR(pszURIShopDrawCard, generate("draw_id=%d", 1)); };
	m_requests["req_buy_item"] = [this]() { return PAIR_STR(pszURIShopBuyItem, generate("item_sessionID=%d&item_order=%d", 700001, 1)); };
	m_requests["req_buy_coin"] = [this]() { return PAIR_STR(pszURIShopBuyCoin, generate("receipt_data=%s&c_idx=%d", "", 1)); };

	// manage
	m_requests["req_enter_manage"] = [this]() { return PAIR_STR(pszURIEnterManage, generate("")); };

	m_requests["req_change_msg"] = [this]() { return PAIR_STR(pszURIManageChangeMsg, generate("user_msg=%s%d", "Stress Test", m_sessionID)); };
	m_requests["req_card_list"] = [this]() { return PAIR_STR(pszURIManageCardList, generate("")); };
	m_requests["req_sell_card"] = [this]() { return PAIR_STR(pszURIManageSellCard, generate("")); };
	m_requests["req_item_list"] = [this]() { return PAIR_STR(pszURIManageItemList, generate("")); };
	m_requests["req_use_item"] = [this]() { return PAIR_STR(pszURIManageUseItem, generate("obj_ref_id=%d", m_sessionID+10)); };
	m_requests["req_update_stat"] = [this]() { return PAIR_STR(pszURIManageUpdateStat, generate("inc_ap_point=%d&inc_bp_point=%d", 1, 1)); };
	// *** 
	m_requests["req_lock_card"] = [this]() { return PAIR_STR(pszURIManageLockCard, generate("inven_id=%d&set_lock=%d", m_sessionID+100, true)); };

	// formation
	m_requests["req_enter_formation"] = [this]() { return PAIR_STR(pszURIEnterFormation, generate("")); };

	m_requests["req_set"] = [this]() { return PAIR_STR(pszURIFormationSet, generate("cd_1=%d&cd_2=%d&cd_3=%d&cd_4=%d&cd_5=%d&battle_ai=%d", m_sessionID + 100, m_sessionID + 101, m_sessionID + 102, m_sessionID + 103, m_sessionID + 104, 0)); };

	// friend
	m_requests["req_list"] = [this]() { return PAIR_STR(pszURIFriendList, generate("")); };
	m_requests["req_delete"] = [this]() { return PAIR_STR(pszURIFriendDelete, generate("friend_pvid=%d", m_sessionID+4)); };

	m_requests["req_propose_list"] = [this]() { return PAIR_STR(pszURIFriendProposeList, generate("")); };
	m_requests["req_accept"] = [this]() { return PAIR_STR(pszURIFriendAccept, generate("requestor_pvid=%d", m_sessionID+2)); };
	m_requests["req_reject"] = [this]() { return PAIR_STR(pszURIFriendReject, generate("requestor_pvid=%d", m_sessionID-1)); };
	m_requests["req_cancel"] = [this]() { return PAIR_STR(pszURIFriendCancel, generate("acceptor_pvid=%d", m_sessionID-1)); };

	m_requests["req_candidate_list"] = [this]() { return PAIR_STR(pszURIFriendCandidateList, generate("")); };
	m_requests["req_search"] = [this]() { return PAIR_STR(pszURIFriendSearch, generate("search_keyword=%d", "PRIME")); };
	m_requests["req_request"] = [this]() { return PAIR_STR(pszURIFriendRequest, generate("acceptor_pvid=%d", m_sessionID + 1)); };

	// post
	m_requests["req_enter_post"] = [this]() { return PAIR_STR(pszURIEnterPost, generate("")); };

	m_requests["req_list"] = [this]() { return PAIR_STR(pszURIPostList, generate("")); };
	m_requests["req_check"] = [this]() { return PAIR_STR(pszURIPostCheck, generate("post_idx=%d", m_sessionID + 1)); };
	m_requests["req_get_item"] = [this]() { return PAIR_STR(pszURIPostGetItem, generate("post_idx=%d", m_sessionID + 1)); };
	m_requests["req_delete"] = [this]() { return PAIR_STR(pszURIPostDelete, generate("post_idx=%d", m_sessionID + 10)); };

	// system
	m_requests["req_user_refresh"] = [this]() { return PAIR_STR(pszURIUserRefresh, generate("")); };
		// noti
	m_requests["req_noti_live"] = [this]() { return PAIR_STR(pszURINotiLive, generate("")); };
	m_requests["req_noti_alert"] = [this]() { return PAIR_STR(pszURINotiAlert, generate("")); };
		// banner
	m_requests["req_front_banner"] = [this]() { return PAIR_STR(pszURIFrontBanner, generate("")); };
}

void CSession::BindActionHandler()
{
	m_actions.insert( MAP_ACTIONS::value_type("req_mission_progress",&CSession::ActionBehaviorAIMissionProgress) );
	m_actions.insert( MAP_ACTIONS::value_type("req_battle_progress",&CSession::ActionBehaviorAIBattleProgress) );
	m_actions.insert( MAP_ACTIONS::value_type("req_raid_progress",&CSession::ActionBehaviorAIRaidProgress) );

	// enter game
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_game",&CSession::ActionBehaviorEnterGame) );

	// ready to play
	m_actions.insert( MAP_ACTIONS::value_type("req_ready_to_play",&CSession::ActionBehaviorReadyToPlay) );
	m_actions.insert( MAP_ACTIONS::value_type("req_set_species",&CSession::ActionBehaviorSetSpecies) );
	m_actions.insert( MAP_ACTIONS::value_type("req_set_name",&CSession::ActionBehaviorSetName) );

	// mission
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_mission",&CSession::ActionBehaviorEnterMission) );
	m_actions.insert( MAP_ACTIONS::value_type("req_quest_progress",&CSession::ActionBehaviorMissionQuestProgress) );

	// battle
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_battle",&CSession::ActionBehaviorEnterBattle) );

	m_actions.insert( MAP_ACTIONS::value_type("req_rank_list",&CSession::ActionBehaviorBattleRankList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_rival_list",&CSession::ActionBehaviorBattleRivalList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_combat_start",&CSession::ActionBehaviorBattleCombatStart) );
	m_actions.insert( MAP_ACTIONS::value_type("req_history_list",&CSession::ActionBehaviorBattleHistoryList) );

	m_actions.insert( MAP_ACTIONS::value_type("req_first_rival",&CSession::ActionBehaviorBattleFirstRival) );
	m_actions.insert( MAP_ACTIONS::value_type("req_first_start",&CSession::ActionBehaviorBattleFirstStart) );
	
	// raid
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_raid",&CSession::ActionBehaviorEnterRaid) );

	m_actions.insert( MAP_ACTIONS::value_type("req_start",&CSession::ActionBehaviorRaidStart) );
	m_actions.insert( MAP_ACTIONS::value_type("req_result",&CSession::ActionBehaviorRaidResult) );

	// enhance
	m_actions.insert( MAP_ACTIONS::value_type("req_upgrade",&CSession::ActionBehaviorCardUpgrade) );
	m_actions.insert( MAP_ACTIONS::value_type("req_evolution",&CSession::ActionBehaviorCardEvolution) );

	// shop
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_shop",&CSession::ActionBehaviorEnterShop) );

	m_actions.insert( MAP_ACTIONS::value_type("req_draw_card",&CSession::ActionBehaviorShopDrawCard) );
	m_actions.insert( MAP_ACTIONS::value_type("req_buy_item",&CSession::ActionBehaviorShopItemBuy) );
	m_actions.insert( MAP_ACTIONS::value_type("req_buy_coin",&CSession::ActionBehaviorShopCoinBuy) );

	// manage
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_manage",&CSession::ActionBehaviorEnterManage) );

	m_actions.insert( MAP_ACTIONS::value_type("req_change_msg",&CSession::ActionBehaviorManageChangeMsg) );
	m_actions.insert( MAP_ACTIONS::value_type("req_card_list",&CSession::ActionBehaviorManageCardList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_sell_card",&CSession::ActionBehaviorManageSellCard) );
	m_actions.insert( MAP_ACTIONS::value_type("req_item_list",&CSession::ActionBehaviorManageItemList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_use_item",&CSession::ActionBehaviorManageUseItem) );
	m_actions.insert( MAP_ACTIONS::value_type("req_update_stat",&CSession::ActionBehaviorManageUpdateStat) );

	// formation
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_formation",&CSession::ActionBehaviorEnterFormation) );

	m_actions.insert( MAP_ACTIONS::value_type("req_set",&CSession::ActionBehaviorFormationSet) );

	// friend
	m_actions.insert( MAP_ACTIONS::value_type("req_list",&CSession::ActionBehaviorFriendList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_delete",&CSession::ActionBehaviorFriendDelete) );

	m_actions.insert( MAP_ACTIONS::value_type("req_propose_list",&CSession::ActionBehaviorFriendProposeList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_accept",&CSession::ActionBehaviorFriendAccept) );
	m_actions.insert( MAP_ACTIONS::value_type("req_reject",&CSession::ActionBehaviorFriendReject) );
	m_actions.insert( MAP_ACTIONS::value_type("req_cancel",&CSession::ActionBehaviorFriendCancel) );

	m_actions.insert( MAP_ACTIONS::value_type("req_candidate_list",&CSession::ActionBehaviorFriendCandidateList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_search",&CSession::ActionBehaviorFriendSearch) );
	m_actions.insert( MAP_ACTIONS::value_type("req_request",&CSession::ActionBehaviorFriendRequest) );

	// post
	m_actions.insert( MAP_ACTIONS::value_type("req_enter_post",&CSession::ActionBehaviorEnterPost) );

	m_actions.insert( MAP_ACTIONS::value_type("req_list",&CSession::ActionBehaviorPostList) );
	m_actions.insert( MAP_ACTIONS::value_type("req_check",&CSession::ActionBehaviorPostCheck) );
	m_actions.insert( MAP_ACTIONS::value_type("req_get_item",&CSession::ActionBehaviorPostGetItem) );
	m_actions.insert( MAP_ACTIONS::value_type("req_delete",&CSession::ActionBehaviorPostDelete) );

	// system
	m_actions.insert( MAP_ACTIONS::value_type("req_user_refresh",&CSession::ActionBehaviorUserRefreshTime) );
		// noti
	m_actions.insert( MAP_ACTIONS::value_type("req_noti_live",&CSession::ActionBehaviorNotiLive) );
	m_actions.insert( MAP_ACTIONS::value_type("req_noti_alert",&CSession::ActionBehaviorNotiAlert) );
		// banner
	m_actions.insert( MAP_ACTIONS::value_type("req_front_banner",&CSession::ActionBehaviorFrontBanner) );

	m_actions.insert( MAP_ACTIONS::value_type("user_reset",&CSession::ActionBehaviorUserReset) );
}

void CSession::BindMsgHandlers()
{
	REG_FRAMEWORKMSG_HANDLE(VS_FORWARDEDMSG_MODULE_CERTIFICATED,OnVS_FORWARDEDMSG_MODULE_CERTIFICATED);
	REG_FRAMEWORKMSG_HANDLE(VSFRAMEWORK_ACCOUNT_REGISTER_ACK,OnVSFRAMEWORK_ACCOUNT_REGISTER_ACK);
	REG_FRAMEWORKMSG_HANDLE(VSFRAMEWORK_LOGIN_ACK,OnVSFRAMEWORK_LOGIN_ACK);
	REG_FRAMEWORKMSG_HANDLE(VSFRAMEWORK_NETWORK_ERROR,OnVSFRAMEWORK_NETWORK_ERROR);	

	//REG_MSG_HANDLE("enter_game_ack", OnLTCBEnterGame );
	// login
	//REG_MSG_HANDLE("ready_to_play_ack", OnLTCBReadyToPlay );

	//// mission
	//REG_MSG_HANDLE("enter_mission_ack", OnLTCBEnterMission);
	//REG_MSG_HANDLE("quest_progress", OnLTCBQuestProgress);

	//REG_MSG_HANDLE("area_list", OnLTCBAreaList);
	//REG_MSG_HANDLE("quest_list", OnLTCBQuestList);
	//
	//// battle
	//REG_MSG_HANDLE("enter_battle_ack", OnLTCBEnterBattle);

	//REG_MSG_HANDLE("rank_list", OnLTCBRankList);
	//REG_MSG_HANDLE("battle_list", OnLTCBBattleRivalList);
	//REG_MSG_HANDLE("battle_result", OnLTCBBattleResult);
	//REG_MSG_HANDLE("battle_history", OnLTCBBattleHistoryList);

	//// raid
	//REG_MSG_HANDLE("enter_raid_ack", OnLTCBEnterRaid);

	//REG_MSG_HANDLE("cur_raid", OnLTCBCurRaid);
	//REG_MSG_HANDLE("raid_start", OnLTCBRaidStart);
	//REG_MSG_HANDLE("raid_result", OnLTCBRaidResult);

	//// enhance
	//REG_MSG_HANDLE("card_upgrade", OnLTCBCardUpgrade);
	//REG_MSG_HANDLE("card_evolution", OnLTCBCardEvolution);

	//// shop
	//REG_MSG_HANDLE("draw_card", OnLTCBDrawCard);
	//REG_MSG_HANDLE("buy_item", OnLTCBBuyItem);
	//REG_MSG_HANDLE("buy_coin", OnLTCBBuyCoin);

	//// manage
	//REG_MSG_HANDLE("enter_manage_ack", OnLTCBEnterManage);

	//REG_MSG_HANDLE("manage_change_msg_ack", OnLTCBManageChangeMsg);
	//REG_MSG_HANDLE("manage_card_list_ack", OnLTCBManageCardList);
	//REG_MSG_HANDLE("manage_sell_card_ack", OnLTCBManageSellCard);
	//REG_MSG_HANDLE("manage_item_list_ack", OnLTCBManageItemList);
	//REG_MSG_HANDLE("manage_use_item_ack", OnLTCBManageUseItem);

	//REG_MSG_HANDLE("set_deck", OnLTCBSetDeck);
	//REG_MSG_HANDLE("msg_change", OnLTCBMsgChange);
	//REG_MSG_HANDLE("use_item", OnLTCBUseItem);
	//REG_MSG_HANDLE("card_sell", OnLTCBCardSell);
	//REG_MSG_HANDLE("stat_up", OnLTCBStatUp);
	//REG_MSG_HANDLE("card_lock", OnLTCBCardLock);
	//
	//// Friend
	//REG_MSG_HANDLE("friend_candidate", OnLTCBFriendCandidateList);
	//REG_MSG_HANDLE("friend_list", OnLTCBFriendList);
	//REG_MSG_HANDLE("friend_acceptor", OnLTCBFriendAcceptorList);
	//REG_MSG_HANDLE("friend_requestor", OnLTCBFriendRequestorList);
	//
	//REG_MSG_HANDLE("friend_search", OnLTCBFriendSearch);
	//REG_MSG_HANDLE("friend_request", OnLTCBFriendRequest);
	//REG_MSG_HANDLE("friend_accept", OnLTCBFriendAccept);
	//REG_MSG_HANDLE("friend_reject", OnLTCBFriendReject);
	//REG_MSG_HANDLE("friend_cancel", OnLTCBFriendCancel);
	//REG_MSG_HANDLE("friend_delete", OnLTCBFriendDelete);

	//// post
	//REG_MSG_HANDLE("enter_post_ack", OnLTCBEnterPost);

	//REG_MSG_HANDLE("post_list", OnLTCBPostList);
	//REG_MSG_HANDLE("post_check", OnLTCBPostCheck);
	//REG_MSG_HANDLE("post_get_item", OnLTCBPostGetItem);
	//REG_MSG_HANDLE("post_delete", OnLTCBPostDelete);

	//// system
	//REG_MSG_HANDLE("user_refresh", OnLTCBUserRefresh);
	//	// Noti
	//REG_MSG_HANDLE("noti_live", OnLTCBNotiLive);
	//REG_MSG_HANDLE("noti_alert", OnLTCBNotiAlert);
	//	// Front Banner
	//REG_MSG_HANDLE("front_banner", OnLTCBFrontBanner);
}

void CSession::OnVS_FORWARDEDMSG_MODULE_CERTIFICATED(unsigned char param)
{
	Put( L"module certificated! session[%d]", m_sessionID );
}

void CSession::OnVSFRAMEWORK_ACCOUNT_REGISTER_ACK(unsigned char param)
{
}

void CSession::OnVSFRAMEWORK_LOGIN_ACK(unsigned char param)
{
	Put( L"session log in!! session[%d]", m_sessionID );
}

void CSession::OnVSFRAMEWORK_NETWORK_ERROR(unsigned char param)
{
	Put( L"!!!!!!!!! net error session[%d] error[%d]", m_sessionID, param );
}
